﻿<Window x:Class="WPF.DataBinding.DataTemplate.DataTemplateWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WPF.DataBinding.DataContext"
        Title="DataTemplateWindow" Height="300" Width="300">
    <Window.Resources>
        <DataTemplate DataType="{x:Type local:Person}">
            <Grid Name="grdDataContext" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Grid.Row="0" Text="Name: "/>
                <TextBlock Grid.Column="0" Grid.Row="1" Text="Surname: "/>
                <TextBlock Grid.Column="0" Grid.Row="2" Text="Age: "/>

                <TextBox Name="txtName"  Grid.Column="1" Grid.Row="0" Text="{Binding Path=Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                <TextBox Name="txtSurname" Grid.Column="1" Grid.Row="1" Text="{Binding Path=Surname,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                <TextBox Name="txtAge" Grid.Column="1" Grid.Row="2" Text="{Binding Path=Age,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>

            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Grid Name="grdDataContext" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <ListView ItemsSource="{Binding}"/>
        
        <StackPanel Grid.Row="1" >
            <Button Name="btnShow" Click="btnShow_Click" Content="_Show"/>
            <Button Name="btnChange" Click="btnChange_Click" Content="Change Age"/>
        </StackPanel>
    </Grid>
</Window>
